<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>医嘱模板</title>
</head>
<link rel="stylesheet" href="../../lib/layui/css/layui.css"/>
<script src="../../lib/layui/layui.js"></script>
<script src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../js/xadmin.js"></script>
<script src="../../js/common.js"></script>
<body>
<!-- 医嘱模板 -->
<form class="layui-form layui-form-pane" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">模板名称</label>
        <div class="layui-input-block">
            <input type="text" placeholder="必填" name="t_name" autocomplete="off" placeholder="请输入模板名称"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">医嘱内容</label>
        <div class="layui-input-block">
            <textarea placeholder="必填" name="t_medical_advice" placeholder="请输入医嘱内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="add">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
</html>
<script>
    layui.use(['element', 'form','layer'], function () {
        var $ = layui.jquery
            , form = layui.form
            , element = layui.element
            . layer = layui.layer;

        //监听提交
        form.on('submit(add)',
            function (data) {
                console.log(data);
                //发异步，把数据提交给php
                useAjax("/JT90/addmedical_advice",data.field,"JSON","GET",function(count){
                    if (count>0){
                        layer.alert("增加成功", {
                                icon: 6
                            },
                            function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                    }else {
                        layer.msg("提交失败",{icon:5});
                    }
                })
                return false;
            });
    })
</script>
